package cn.itcast.usermanage.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.abel533.entity.Example;

import cn.itcast.usermanage.mapper.SearchMapper;
import cn.itcast.usermanage.pojo.Search;

@Service
public class SearchService {
    
    @Autowired
    private SearchMapper searchMapper;

    public List<Search> queryByDir(Search record) {
        // TODO Auto-generated method stub
        Example example = new Example(Search.class);
        example.createCriteria().andEqualTo("direction",record.getDirection());
        return this.searchMapper.selectByExample(example);
    }

    public List<Search> queryByType(String type) {
        // TODO Auto-generated method stub
        Search record = new Search();
        record.setType(type);
        return this.searchMapper.select(record);
    }

    public int queryCount(Search record) {
        // TODO Auto-generated method stub
        return this.searchMapper.selectCount(record);
    }

    public Search queryById(int id) {
        // TODO Auto-generated method stub
        
        return this.searchMapper.selectByPrimaryKey(id);
    }

    public List<Search> queryAll() {
        // TODO Auto-generated method stub
        return this.searchMapper.select(null);
    }

    public Search queryone(Search record) {
        // TODO Auto-generated method stub
        return this.searchMapper.selectOne(record);
    }

    public List<Search> queryByTy(Search record) {
        // TODO Auto-generated method stub
        Example example = new Example(Search.class);
        example.createCriteria().andEqualTo("type", record.getType());
        return this.searchMapper.selectByExample(example);
    }

   

}
